!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@floating-ui/dom"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","@floating-ui/dom","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FloatingUIReactDOM={},e.FloatingUIDOM,e.React,e.ReactDOM)}(this,(function(e,t,n,r){"use strict";function o(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var u=o(n),i=o(r);var f="undefined"!=typeof document?n.useLayoutEffect:n.useEffect;function c(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if("function"==typeof e&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&"object"==typeof e){if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;0!=r--;)if(!c(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;0!=r--;){const n=o[r];if(("_owner"!==n||!e.$$typeof)&&!c(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function a(e){if("undefined"==typeof window)return 1;return(e.ownerDocument.defaultView||window).devicePixelRatio||1}function l(e,t){const n=a(e);return Math.round(t*n)/n}function s(e){const t=u.useRef(e);return f((()=>{t.current=e})),t}Object.defineProperty(e,"autoPlacement",{enumerable:!0,get:function(){return t.autoPlacement}}),Object.defineProperty(e,"autoUpdate",{enumerable:!0,get:function(){return t.autoUpdate}}),Object.defineProperty(e,"computePosition",{enumerable:!0,get:function(){return t.computePosition}}),Object.defineProperty(e,"detectOverflow",{enumerable:!0,get:function(){return t.detectOverflow}}),Object.defineProperty(e,"flip",{enumerable:!0,get:function(){return t.flip}}),Object.defineProperty(e,"getOverflowAncestors",{enumerable:!0,get:function(){return t.getOverflowAncestors}}),Object.defineProperty(e,"hide",{enumerable:!0,get:function(){return t.hide}}),Object.defineProperty(e,"inline",{enumerable:!0,get:function(){return t.inline}}),Object.defineProperty(e,"limitShift",{enumerable:!0,get:function(){return t.limitShift}}),Object.defineProperty(e,"offset",{enumerable:!0,get:function(){return t.offset}}),Object.defineProperty(e,"platform",{enumerable:!0,get:function(){return t.platform}}),Object.defineProperty(e,"shift",{enumerable:!0,get:function(){return t.shift}}),Object.defineProperty(e,"size",{enumerable:!0,get:function(){return t.size}}),e.arrow=e=>({name:"arrow",options:e,fn(n){const{element:r,padding:o}="function"==typeof e?e(n):e;return r&&(u=r,{}.hasOwnProperty.call(u,"current"))?null!=r.current?t.arrow({element:r.current,padding:o}).fn(n):{}:r?t.arrow({element:r,padding:o}).fn(n):{};var u}}),e.useFloating=function(e){void 0===e&&(e={});const{placement:n="bottom",strategy:r="absolute",middleware:o=[],platform:d,elements:{reference:p,floating:m}={},transform:g=!0,whileElementsMounted:b,open:y}=e,[O,P]=u.useState({x:0,y:0,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[w,j]=u.useState(o);c(w,o)||j(o);const[h,v]=u.useState(null),[R,S]=u.useState(null),x=u.useCallback((e=>{e!=A.current&&(A.current=e,v(e))}),[v]),M=u.useCallback((e=>{e!==C.current&&(C.current=e,S(e))}),[S]),k=p||h,D=m||R,A=u.useRef(null),C=u.useRef(null),E=u.useRef(O),F=s(b),U=s(d),q=u.useCallback((()=>{if(!A.current||!C.current)return;const e={placement:n,strategy:r,middleware:w};U.current&&(e.platform=U.current),t.computePosition(A.current,C.current,e).then((e=>{const t={...e,isPositioned:!0};z.current&&!c(E.current,t)&&(E.current=t,i.flushSync((()=>{P(t)})))}))}),[w,n,r,U]);f((()=>{!1===y&&E.current.isPositioned&&(E.current.isPositioned=!1,P((e=>({...e,isPositioned:!1}))))}),[y]);const z=u.useRef(!1);f((()=>(z.current=!0,()=>{z.current=!1})),[]),f((()=>{if(k&&(A.current=k),D&&(C.current=D),k&&D){if(F.current)return F.current(k,D,q);q()}}),[k,D,q,F]);const I=u.useMemo((()=>({reference:A,floating:C,setReference:x,setFloating:M})),[x,M]),T=u.useMemo((()=>({reference:k,floating:D})),[k,D]),$=u.useMemo((()=>{const e={position:r,left:0,top:0};if(!T.floating)return e;const t=l(T.floating,O.x),n=l(T.floating,O.y);return g?{...e,transform:"translate("+t+"px, "+n+"px)",...a(T.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:t,top:n}}),[r,g,T.floating,O.x,O.y]);return u.useMemo((()=>({...O,update:q,refs:I,elements:T,floatingStyles:$})),[O,q,I,T,$])}}));
